package com.goods.controller.business;

import com.goods.business.service.HealthService;
import com.goods.common.model.business.Health;
import com.goods.common.response.ActiveUser;
import com.goods.common.response.ResponseBean;
import com.goods.common.vo.business.HealthVO;
import com.goods.common.vo.system.PageVO;
import com.goods.common.vo.system.UserInfoVO;
import org.apache.shiro.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import java.util.List;

@RestController
@RequestMapping("/business/health")
public class HealthController {


    @Autowired
    private HealthService healthService;


    /**
     * 健康打卡提示
     * @return
     */
    @GetMapping("/isReport")
    public ResponseBean isReport(){
        Health health = healthService.isReport();
        if (health != null){
            return ResponseBean.success(health);
        }
        return ResponseBean.success();
    }


    /**
     * 打卡
     * @param healthVO
     * @return
     */
    @PostMapping("/report")
    public ResponseBean report(@RequestBody HealthVO healthVO){
        healthService.report(healthVO);
        return ResponseBean.success();
    }


    /**
     * 查询签到记录
     * @return
     * pageSize=4&pageNum=1
     */
    @GetMapping("/history")
    public ResponseBean history(@RequestParam("pageSize")int pageSize,
                                @RequestParam("pageNum")int pageNum){
        PageVO<Health> pageVO = healthService.history(pageSize,pageNum);
        if (pageVO != null){
            return ResponseBean.success(pageVO);
        }
        return ResponseBean.success();
    }

}
